<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%--
  Created by IntelliJ IDEA.
  User: qupen
  Date: 2016/11/29
  Time: 9:40
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<jsp:include page="../include/head.jsp">
    <jsp:param name="title" value="日志文件管理"/>
</jsp:include>

<jsp:include page="../include/admin_header.jsp"/>

<jsp:include page="../include/admin_sidebar.jsp"/>

<div class="content-wrapper">
    <section class="content-header">
        <h4 class="page-title"><spring:message code="label.user.edit.info"/></h4>
    </section>
    <section class="content">
        <div class="box box-primary">
            <div class="box-body">
                <div class="form-horizontal">
                    <div class="sie-padding-top">
                        <div class="form-group form-group-change">
                            <label class="col-md-5 sie-left-name"><spring:message code="label.admin.user.login.log"/>:</label>

                            <div class="col-md-7">
                                <input id="login-log" class="form-control sie-input-border sie-input-uwh" value="${logsInfo.adminLog}"/>
                            </div>
                        </div>
                        <div class="form-group form-group-change">
                            <label class="col-md-5 sie-left-name"><spring:message code="label.admin.operation.log"/>:</label>

                            <div class="col-md-7">
                                <input id="admin-log" class="form-control sie-input-border sie-input-uwh" value="${logsInfo.dbLog}"/>
                            </div>
                        </div>
                        <div class="form-group form-group-change">
                            <label class="col-md-5 sie-left-name"><spring:message code="label.tenant.admin.operation.log"/>:</label>

                            <div class="col-md-7">
                                <input id="tenant-log" class="form-control sie-input-border sie-input-uwh" value="${logsInfo.loginLog}"/>
                            </div>
                        </div>
                        <div class="form-group form-group-change">
                            <label class="col-md-5 sie-left-name"><spring:message code="label.admin.data.backup.operation.log"/>:</label>

                            <div class="col-md-7">
                                <input id="db-log" class="form-control sie-input-border sie-input-uwh" value="${logsInfo.tenantLog}"/>
                                <div style="margin-top: 79px;">
                                    <a id="edit_button" class="solid-button-blue" href="javascript:;"><spring:message code="label.save"/></a>
                                    <a class="solid-button-orange" href="javascript:history.back(-1);"><spring:message code="label.cancel"/></a>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>
</div>
<jsp:include page="../include/foot.jsp"/>
<script>
    $(document).ready(function () {
        $('#edit_button').click(function () {
            $.ajax({
                type: "post",
                url: "/admin/api/v1/config/logs",
                contentType:"application/json;charset=utf-8",
                data: JSON.stringify({
                    loginLog: $("#login-log").val(),
                    adminLog: $("#admin-log").val(),
                    tenantLog: $("#tenant-log").val(),
                    dbLog: $("#db-log").val()
                }),
                success: function (data) {
                    swal({
                        title: '<spring:message code="label.create.success"/>',
                        text: "",
                        type: "success",
                        showCancelButton: false,
                        showConfirmButton: true,
                        confirmButtonText: '<spring:message code="label.admin.confirm"/>',
                        animation: "slide-from-top"
                    }, function () {
                        window.location.reload();
                    });
                },
                error: function (e) {
                    console.log(e);
                }
            });
        })
    })
</script>